home *** CD-ROM | disk | FTP | other *** search
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 1
-
-
-
- Documentation for ANIMATE
-
-
-
- Overview
-
- ANIMATE creates and displays animated movies on IBM-
- compatible personal computers by reading one or more files
- containing a sequence of Tektronix 4010 (Tek4010) monochrome
- graphics. Movies are limited in length only by the capacity of
- the user's hard disk. For the user who knows C, functions
- supplied with ANIMATE can be embedded into the user's own PC
- graphics programs to make movies of whatever graphics those
- programs create. Those movies can then be viewed with ANIMATE.
-
-
- Table of Contents
-
- Overview, table of contents, and copyright . . . 1
- Hardware requirements . . . . . . . 2
- Software needed to complement ANIMATE . . . . 2
- Files which comprise the ANIMATE package. . . . 3
- Glossary . . . . . . . . . . 4
- Installing ANIMATE . . . . . . . . 6
- Using ANIMATE to construct and view a movie . . . 6
- Plotting Tektronix graphics onto a rasterized background 7
- Editing ANIMATE.PAR and "script" files . . . . 8
- If you have trouble with ANIMATE . . . . . 11
- Optimizing ANIMATE's performance . . . . . 11
- Comments on ANIMATE's Tektronix emulation . . . 12
- Modifying ANIMATE . . . . . . . . 13
- Compiling ANIMATE . . . . . . . . 14
- Bugs in Turbo C . . . . . . . . 15
- References. . . . . . . . . . 16
- Acknowledgments. . . . . . . . . 16
-
-
-
- Copyright 1990 by Jon Ahlquist, Department of Meteorology B-161,
- Florida State University, Tallahassee, Florida 32306-3034, USA.
- Telephone: (904) 644-1558.
- Internet address:
- ahlquist@metsat.met.fsu.edu (ahlquist@128.186.5.2)
-
- This document and the files listed herein may be freely copied
- without charge, provided copyright notices are left intact. All
- software and documentation is provided "as is" without warranty
- of any kind.
-
- Development of this material was sponsored by NSF grant ATM-
- 8714674.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 2
-
-
- Hardware requirements to run ANIMATE
-
- ANIMATE requires an IBM-compatible PC with a hard disk and a
- register level compatible EGA, VGA, or monochrome Hercules
- graphics board. The only way to find out whether your graphics
- board is suitable is to try ANIMATE. Unfortunately, many older
- "clone" graphics boards do not meet all the requirements for true
- register level compatibility. Video boards compatible with
- Hercules monochrome graphics at the register level are available
- in the U.S. by mail order for under $100. More expensive but
- more powerful are boards like the Everex EVGA board, which
- supports Hercules monochrome, EGA, VGA, and a number of other
- modes. Such boards require a multi-sync monitor to display all
- their modes.
- Only the 640 by 350 pixel, 16 color mode of EGA/VGA graphics
- and Hercules monochrome graphics are supported by ANIMATE because
- these are the only two standard graphics modes used on IBM PCs
- that offer video "double buffering" (see the glossary).
- Since most Tektronix graphs will be generated on a mainframe
- computer and then transferred to a microcomputer running ANIMATE,
- an important factor is the time it takes to send the graphics
- file(s) from the mainframe to the microcomputer. For movies that
- contain more than a few frames of graphics, a 9600 baud
- connection between the microcomputer and mainframe is almost
- essential. A Local Area Network (LAN) like Ethernet is helpful
- in this regard. A telephone line may be too noisy, unless error
- correcting file transfer software is used; but such software
- running with a 1200 baud modem would be very slow.
- If you know C, you may decide to write some or all of your
- graphics directly in Turbo C and thereby avoid the transmission
- time between mainframe and micro. If so, you can use the program
- in file "makemovy.c" as an example of how to proceed.
-
- Software needed to complement ANIMATE
-
- If you generate Tek4010 graphics using a mainframe or
- minicomputer, you will need communications software so that your
- microcomputer can "capture" the graphics generated by the other
- computer. This software is not supplied with ANIMATE, but it is
- widely available. Since Tek4010 graphics commands are composed
- of standard ASCII characters, any communications software that
- can capture an ASCII file will be suitable; the package need not
- have any graphics capabilities at all. For example, Procomm, a
- common, low cost, shareware communications program, can capture a
- Tek4010 file because it can capture any ASCII file. A copy of
- the latest version of Procomm with documentation on disk can be
- purchased for $35 from Datastorm Technologies, Inc., P.O. Box
- 1471, Columbia, MO 65205.
- Users of TCP/IP, i.e. Internet, can acquire public domain
- NCSA Telnet software with documentation on disk for a $20
- handling fee from: NCSA Telnet for the PC -- Orders, 152
- Computing Applications Building, 605 E. Springfield Ave.,
- Champaign, IL 61820. Telnet software does NOT work with a modem
- and telephone line; it works only with a TCP/IP network.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 3
-
-
- Files which comprise the ANIMATE package
-
- ANIMATE.DOC This documentation.
- ANIMATE1.C Source code for function main() of ANIMATE.
- ANIMATE2.C Source code for auxiliary functions for ANIMATE,
- including functions to save and display
- rasterized images. These functions can be
- inserted into your own Turbo C programs.
- ANIMATE.PRJ Project file.
- ANIMATE.EXE Executable version of ANIMATE.
- ANIMATE.PAR Parameter file configured for EGA graphics and
- Tek4010 graphics.
- ANIMATE.HER Hercules monochrome version of ANIMATE.PAR.
- If you have a Hercules monochrome graphics board,
- rename ANIMATE.PAR to ANIMATE.PAE, then
- rename ANIMATE.HER to ANIMATE.PAR.
- MAP.TEK Tek4010 plot file containing a short
- movie consisting of a few world maps from a
- satellite's perspective.
- MAP.SCR Script file for showing the example movie
- with different colors than those specified
- in ANIMATE.PAR.
- MAKEMOVY.C Example program showing how a file of
- rasterized images can be created directly
- using the graphics in Turbo C.
- The program also shows the difference
- between single and double buffering of images.
- MAKEMOVY.PRJ Project file for MAKEMOVY.C.
- GRAFSUPP.C Supplemental graphics files used by MAKEMOVY.PRJ.
- Some or all of the functions in this file may be
- useful for your own Turbo C graphics programs.
- GRAFSUPP.H Header file to accompany GRAFSUPP.C.
- GRAFDEMO.C Demonstration program which calls the routines
- in GRAFSUPP.C. Does not make a movie but runs
- with any graphics mode supported by Turbo C.
- GRAFDEMO.PRJ Project file for GRAFDEMO.C.
- TESTPIC.C Program to create a file in Tektronix 4010 format.
-
-
- If you wish to modify ANIMATE, you must have version 2 or
- newer of Borland's Turbo C. This is available inexpensively by
- mail order or through your local dealer. Educational customers
- can purchase Turbo C at especially attractive prices direct from
- Borland; call Borland's sales office at (408) 439-1064 and ask
- for Educational Sales.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 4
-
-
- Glossary
-
- Knowledge of the following computer graphics terms is essential
- to understanding the operation of ANIMATE. The definitions also
- include extra information specific to ANIMATE.
-
- PIXEL means "picture element." Computer text and graphics are
- composed of hundreds of columns and hundreds of rows of tiny
- rectangular "pixels." The precise number of pixels in a screen
- depends on the video mode you are using. Hercules monochrome
- graphics have 720 columns by 348 rows of pixels for a total of
- 250,560 pixels per screen, while high resolution EGA graphics
- (medium resolution VGA graphics) have 640 rows by 350 columns for
- a total of 224,000 pixels per screen. A Hercules pixel is either
- off or on, i.e. dark or lit. An EGA pixel can be any of 16
- different colors chosen from a palette of 64 colors.
-
- VECTOR GRAPHICS are constructed by drawing a collection of line
- segments. Vector graphics may be monochrome or color. Usually,
- only a small fraction of the total number of pixels are involved
- in vector graphics.
-
- IMAGES are pictures which are more complicated than just a set of
- lines. For example, a very young child draws stick figures to
- represent objects; these are vector graphics. As the child
- matures, the child's drawing will include shading. Shaded
- regions cannot be represented accurately using line segments.
- Such pictures are called images.
-
- RASTERIZED IMAGES are like television pictures. An image is
- created by defining every pixel on the screen. Any picture
- displayed by an IBM-compatible PC is a rasterized image, because
- every pixel is defined (although many are often set to be the
- background color). ANIMATE stores rasterized images for its
- movies rather than staying with the more compact files that hold
- Tektronix vector graphics for two reasons: (1) an IBM-compatible
- PC can load a rasterized image faster than it can draw a
- complicated vector graphics plot, and (2) the rate at which a
- movie of rasterized images is shown is independent of the
- complexity of the images, because every pixel is always loaded.
-
- DOUBLE BUFFERING of image input means that you are viewing one
- picture stored in one part (one "page") of a graphics board's
- memory while the next image is being loaded into a second page of
- video memory. When this next picture is ready, then it is
- displayed. That leaves the first page of video memory free for
- loading the third picture, etc. With double buffering, you see
- only complete images and flickerless animation. Without double
- buffering, you see images being painted onto the screen or
- flicker. ANIMATE does not use double buffering when emulating a
- Tektronix terminal so that you will see the images being drawn,
- but it does use double buffering for showing movies, i.e.
- replaying rasterized images.
- To demonstrate single versus double buffering, I have
- included program "MAKEMOVY." Even modern Basic allows double
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 5
-
-
- buffering with its SCREEN command. Microsoft's QuickBasic works
- fine, but Borland's Turbo Basic SCREEN command has a bug that
- prevents proper use of the second page of video memory for at
- least EGA graphics. Remember, only Hercules monochrome and the
- 640 by 350 pixel mode of EGA/VGA graphics offer double buffering.
- CGA and the other VGA modes cannot double buffer.
-
- BIT PLANES refer to a memory system used to store the color of
- each pixel. Let's say that each pixel has N bits available to
- denote its color; with EGA/VGA 16 color graphics, N=4. If bit
- planes are used, as they are with EGA/VGA graphics, there are N
- "planes" of memory. The first bit plane holds the rightmost
- (least significant) bit of each pixel. The next bit plane holds
- the next most significant bit of each pixel, etc. until we reach
- the N-th bit plane which holds the N-th bit of each pixel. When
- ANIMATE operates in EGA/VGA mode, it must know how many of the
- four bit planes the user wishes to use. All necessary
- information for a monochrome image can be stored in one bit
- plane. Two bit planes provide four colors; three bit planes, 8
- colors; four bit planes, 16 colors.
-
- PALETTE is the name given to the color table that relates the
- 4 bits reserved for each EGA pixel with the 6-bit integers that
- represent the various possible EGA colors. 4 bits represent
- numbers between 0 and 15, while 6 bits represent numbers between
- 0 and 63. Therefore, only 16 of the possible 64 EGA colors can
- actually be used in any given palette. 64 colors are possible
- because each pixel can contain three primary colors (red, green,
- and blue) and three secondary colors (light red, green, and
- blue). See Wilton (1987) for a few more details, but so far I
- have not figured out to decode an arbitrary 6 bit integer into a
- combination of "normal" and "light" reds, greens, and blues. The
- problem for me lies with colors that involve the high 3 bits,
- i.e. color numbers greater than 7. The table below shows the
- standard EGA assignment of colors to base 10 pixel values.
-
- Pixel Color number (base 10) Pixel Color number (base 10)
- value and color value and color
- 0 0 black 8 56 dark gray
- 1 1 blue 9 57 light blue
- 2 2 green 10 58 light green
- 3 3 cyan 11 59 light cyan
- 4 4 read 12 60 light red
- 5 5 magenta 13 61 light magenta
- 6 7 light gray 14 62 yellow
- 7 20 brown 15 63 white
-
- For example, if the value of a pixel is 7, standard EGA graphics
- would display it as color number 20, which looks like brown.
- The palette can be changed; that is, any one of the 63
- possible EGA colors could be assigned to the 16 possible pixel
- values. This is one of ANIMATE's options that will be explained
- later.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 6
-
-
- Installing ANIMATE
-
- On your hard disc, create a directory called ANIMATE, and
- copy all the ANIMATE software into that directory. The disk
- should have several unused megabytes. You'll need that much
- space once you start making movies because each frame of Hercules
- graphics or each bit plane of EGA graphics occupies about 30
- kilobytes. If you make a movie containing 100 frames of Tek4010
- graphics, it will occupy about 3 MB of disk space. Don't forget
- to back up your ANIMATE software onto "floppy" disks for safety's
- sake.
-
- As provided, the parameter file ANIMATE.PAR is configured
- for EGA/VGA graphics using one bit plane, which is all Tek4010
- graphics need. If you have Hercules monochrome graphics, you
- need a version of ANIMATE.PAR for Hercules graphics. To do this,
- you need to rename two files; enter the MS-DOS commands:
- REN ANIMATE.PAR ANIMATE.PAE
- REN ANIMATE.PAH ANIMATE.PAR
- If you have EGA or VGA graphics, skip those two commands, because
- ANIMATE.PAR is already set up for you. Just to be safe, enter
- TYPE ANIMATE.PAR to list the contents of the parameter file. The
- first line should say Hercules or EGA. (If you have VGA
- graphics, ANIMATE.PAR should say EGA.)
-
-
- Using ANIMATE to create and view a movie
-
- Type ANIMATE to invoke ANIMATE.EXE. This will call up a
- menu of choices followed by an alphabetical list of the files in
- the current directory. No more than 100 file names will be
- displayed. If the graphics files are not in the current
- directory, you may want to hit the 'c' key to change the active
- disk and/or directory; then type the disk and/or directory just
- as you would for MS-DOS. For example, if your graphics files are
- on the same disk as ANIMATE -- say, the "c:" disk -- but in a
- different directory named \MOVIES, you can enter either C:\MOVIES
- or \MOVIES. Note: Either upper or lower case is fine for
- answering any of ANIMATE's questions.
-
- As an example, we'll make a movie using the supplied file
- MAP.TEK, which you probably have in the same directory with
- ANIMATE. Select Tek4010 emulation by hitting 't.' Type MAP.TEK
- as the name of the first file. Type DONE as the second file name
- to indicate that all files have been entered. Answer no ('n') to
- the next question about using a rasterized background; we'll
- discuss that later. Answer yes ('y') to the question about sav-
- ing the images in rasterized form. Enter MAP.EGA or MAP.HER,
- depending on whether you are using EGA or Hercules graphics. (I
- use the suffix TEK for files that hold Tektronix plot instruc-
- tions, the suffix EGA for files that hold rasterized images in
- EGA format, and the suffix HER for files that hold rasterized
- Hercules images. ANIMATE does not force this convention on you,
- though.) Lastly, you must enter which of the Tektronix plots are
- to be saved in rasterized form. Enter 0 0 to save all frames.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 7
-
-
-
- At this point, you should see a sequence of maps being drawn
- on the screen, and you should hear your hard disk whir as it
- reads Tektronix plotting instructions and saves the rasterized
- images. After all the images have been drawn, control will auto-
- matically return to ANIMATE's main menu.
-
- To view the movie you have just made, hit 'r' to select
- rasterized replay. Enter MAP.EGA or MAP.HER as the first file
- name and DONE as the second. Answer no to the question about
- saving images in rasterized format, unless you would like to save
- a subsequence from this movie. When the movie starts, you should
- see a smooth sequence of world maps appear on your screen. If
- you do not see a smooth sequence of maps without flicker, then
- your graphics board is not register level compatible with EGA or
- Hercules graphics, and you are out of luck as far as ANIMATE is
- concerned. In any case, ANIMATE will continuously repeat a movie
- until the user hits the Escape key (Esc) to escape to the main
- menu. While the movie is running, the user can hit any one of
- the following keys (upper or lower case) in order to select the
- option described.
-
- Choice: Result:
- s Slower movie replay. Hitting 's' more than once
- makes the movie run even slower.
- f Faster movie replay. When a movie first starts,
- it is running as fast as possible, so hitting 'f' will
- have no effect unless 's' has been hit first.
- 1 Toggle single step mode on or off. (Note: 1 is the
- digit one, not a lower case ell.)
- n When in single step mode, this will display the next
- picture.
- p Toggle brief (roughly 1 second) pause at the end of
- movie before repeating it.
- Esc key Go to the main menu. Control C has the same effect.
-
- Default conditions:
- 1. The movie is displayed as fast as possible.
- 2. Single step mode is off; the movie automatically advances from
- one picture to the next.
- 3. There is no pause at the end of the movie before beginning to
- show the movie again.
-
-
- Plotting Tektronix graphs onto a rasterized background
-
- Now we are ready to explain the option under Tektronix
- emulation that asks whether you want your graphs plotted on a
- rasterized background image. Let's suppose that you want to make
- a movie of weather maps. Each picture will show a map and on top
- of that map you will plot lines and symbols that show what the
- weather is. We'll assume that you have already debugged your
- program by making a few test plots. At this point, you could do
- a production run of plots for ANIMATE, and everything would work
- fine, and you could forget about the "rasterized background"
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 8
-
-
- option. Nonetheless, an extra step may be advantageous.
-
- It is inefficient to send the same complicated map to your
- microcomputer over and over again with every picture. The
- following procedure saves execution time, transmision time, and
- disc space at the expense of some of your time. After debugging,
- run your graphics program twice. The first time, draw one single
- picture that contains the constant background that you want to
- appear in each frame of your movie; turn off the rest of the
- plotting commands by converting them into comments. For the
- second run, turn the "background" plotting commands into com-
- ments, restore the other plotting commands, and produce your
- whole movie without a background. Send the two plot files -- one
- contains a single frame (the unchanging background), and the
- other contains as many frames as will be in your movie -- to your
- microcomputer, and capture them using your communications soft-
- ware.
-
- On the microcomputer, invoke ANIMATE. Select Tektronix
- emulation, and create and store a rasterized version of the
- background map. Next, select Tektronix emulation, and enter the
- file name(s) holding the mapless graphics, ending with "done."
- Answer yes ('y') to using a rasterized background image, and
- enter the name of the file that holds the rasterized version of
- the map. For every frame of your movie, ANIMATE will read the
- background map and plot the other graphics on top of it.
-
- There is also a fancier use for the rasterized background
- option. You can combine two or more movies into one movie by
- overlaying them on top of each other. To do this, generate the
- Tek4010 graphics for each of the movies, transmit them to your
- microcomputer, and capture them. Then invoke ANIMATE. For the
- first movie, select Tektronix emulation with no rasterized
- background, and store that movie. For the next movie, select
- Tektronix emulation, and enter the file name(s). Answer yes to
- using a rasterized background, and enter the name of the file
- that contains the first rasterized movie. ANIMATE will display
- the first frame of the first movie and plot on top of it the
- first frame of the second movie, etc. If the first movie ends
- before the second does, the first movie will be "rewound" and
- started again. This is useful if the background for your movie
- is a repetitive sequence.
-
-
- Editing the parameter file ANIMATE.PAR and "script files".
-
- ANIMATE.PAR contains all the adjustable information which
- ANIMATE needs to define its graphics. ANIMATE.PAR is an ASCII
- file which can be edited by any text editor such as the
- NONDOCUMENT mode of WordStar. What I call a "script" file
- contains the same kind of information that ANIMATE.PAR does plus
- the names of files containing rasterized images that you want to
- link together into a movie. Once you understand how to construct
- ANIMATE.PAR, you can build a script file by starting with the
- same types of information as are required for ANIMATE.PAR and
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 9
-
-
- then following that by the file name(s) for the rasterized images
- you want to see. With either ANIMATE.PAR or a script file, do
- not use any commas; just leave one or more spaces between all
- entries.
-
- If you have Hercules monochrome graphics, ANIMATE.PAR should
- contain only two lines. The first line should say "Hercules"
- (without quotes), and the second line should have the x and y
- pixel coordinates of the point at which you want the frame number
- displayed when that option is selected during replay of
- rasterized images. 0 0 refers to the upper left corner of the
- screen. 719 347 is the lower right corner for Hercules graphics.
- 0 10 is often a good place to display frame numbers, which will
- place the frame numbers near the upper left corner of the screen.
-
- If you have EGA or VGA graphics, ANIMATE.PAR must contain
- five lines. The first line should say "EGA" (without quotes).
- The second line must give the number of bit planes to be handled
- in normal operation. Usually, this is 1. The third line must
- contain sixteen integers (base 10) listing the EGA colors that
- are to be assigned to the palette. (See the explanation of the
- palette in the glossary.) Do NOT separate the integers with
- commas; that would cause an error. (The program may not bomb,
- but colors will not be read correctly.) Just leave one or more
- spaces between the numbers.
-
- For EGA/VGA monochrome graphics, only the first bit plane is
- needed. I like yellow lines plotted on a blue background, and I
- have specified this in the supplied copy of ANIMATE.PAR, whose
- third line reads:
- 1 62 0 0 0 0 0 0 0 0 0 0 0 0 0 0
- Thus, color 1 (blue) is shown when a pixel value is 0, and color
- 62 (yellow) is shown when a pixel value is 1. So blue is the
- background color, and yellow is the foreground color. The
- remaining color assignments for pixel values 2 through 15 are
- arbitrary because those colors will never appear if only one bit
- plane is loaded; I have chosen color 0 (black). Another example
- of color assignment is given below where script files are
- discussed.
-
- The fourth line of ANIMATE.PAR for EGA graphics specifies
- the color to be used when writing frame numbers on the pictures.
- The color is indicated by the PIXEL VALUE to be assigned (0
- through 15), NOT by the actual color number (0 to 63). In the
- supplied version of ANIMATE.PAR, the fourth line is 1. That
- means that, when frame numbers are written onto images, it will
- be done by assigning a value of 1 to the affected pixels. Given
- the color assignments indicated in the preceding paragraph, that
- means that the frame numbers will appear in color number 62
- (yellow).
-
- The fifth line of ANIMATE.PAR for EGA graphics must contain
- the x and y pixel coordinates of the point at which you want the
- frame number to be displayed. 0 0 is the upper left corner of
- the screen. 639 349 is the the lower right corner. 0 10 is
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 10
-
-
- often a good place to display frame numbers, which will place the
- frame numbers near the upper left corner of the screen.
-
- A script file holds a "script" for displaying rasterized
- images. It offers two features. One, it allows graphics mode
- assignments to be temporarily reset from the normal values
- specified in ANIMATE.PAR. Second, if more than one file contains
- the rasterized images for a movie, you only have to enter the
- file names once into this file, rather than manually type all the
- file names each time you want to view the movie, as you would
- have to do if you selected ANIMATE's option to "replay rasterized
- images."
-
- The first part of a script file is constructed in exactly
- the same way as ANIMATE.PAR. That is, if your movie uses
- Hercules graphics, the first line of the script file must say
- "Hercules" (without quotes), and the second line must give the x
- and y pixel coordinates where frame numbers are to be written.
- If your movie uses EGA or VGA graphics, a script file must start
- with five lines defining the EGA graphics parameters. These
- lines can be different than what is in ANIMATE.PAR.
-
- As an example where a script file would be nice, let's
- suppose that your mainframe computer has 3-D graphics routines
- that allow you to set the viewing angle of a plot in perspective
- and that you have EGA or VGA graphics on your microcomputer. If
- so, you have what you need to make 3-D movies using the method
- where you draw one eye's view in red and the other eye's view in
- green. You should generate Tek4010 monochrome graphics with two
- views of every image. All of the even numbered frames should be
- one eye's view and all the odd numbered frames should be the
- other eye's view. Your script file for ANIMATE should be some-
- thing like this:
-
- EGA
- 2
- 0 2 4 6 0 0 0 0 0 0 0 0 0 0 0 0
- 1
- 0 10
- FILE1.EGA
- FILE2.EGA
- FILE3.EGA
- etc. up to a maximum of
- FILE10.EGA
-
- With this assignment, two bit planes will be loaded to form each
- image. The background will be black (color 0). The first
- rasterized image read will be placed into the first bit plane,
- and the nonzero pixels will appear in color 2 (red). The second
- image will be loaded into the second bit plane, and its nonzero
- pixels will appear in color 4 (green). In cases where a pixel is
- used in both bit planes, the pixel value will be 1+2=3, to which
- I suggest assigning color 6 because that color (not one of the
- standard EGA colors) is constructed by displaying both red (color
- 2) and green (color 4).
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 11
-
-
-
- You must view such 3-D movies with special glasses. The
- Bulletin of the American Meteorological Society for February 1981
- included a red/green viewer for 3-D pictures, or you can make a
- crude but adequate viewer using cardboard, red and green
- cellophane, tape, and scissors. I have not done much with 3-D
- movies other than to run the sample movie (MAP.EGA) with the
- script file shown above. The result is not satisfying. I
- suspect that the user will have to experiment for a while before
- good 3-D movies result. Please let me know of your successes.
-
-
- If you have trouble with ANIMATE
-
- The most common problem will be that Tektronix emulation
- works okay, but the rasterized replay does not work. Most
- likely, the problem lies with your graphics board. Animation
- on an IBM-compatible PC pushes the capabilities of graphics
- boards, and only some graphics boards meet all the standards of
- Hercules monochrome or IBM EGA graphics.
-
- Nonetheless, a few things should be checked before you
- consider upgrading your graphics board.
-
- 1. Double check the contents of ANIMATE.PAR. The only two
- supported graphics modes are EGA (or equivalently VGA) and Her-
- cules. If you have CGA graphics or EGA graphics with only 64KB
- of memory on the video board, you are out of luck. Secondly,
- make sure that no commas appear in ANIMATE.PAR; entries should be
- separated only by blanks.
-
- 2. Some video boards require that you run a program supplied by
- the boards manufacturer in order to set the board into a certain
- mode of operation. For example, normally I keep my Everex EVGA
- board in EGA mode (actually, in MS-DOS, I execute "EVGAMODE 5").
- If I want to look at a movie of rasterized Hercules images, I
- must first execute EVGAMODE 23 in MS-DOS to switch the board into
- Hercules mode; just specifying "Hercules" in ANIMATE.PAR or in a
- script file is not enough. Curiously, if the EVGA board is in
- Hercules mode, it will correctly switch itself temporarily into
- EGA mode if ANIMATE.PAR or a script file calls for EGA graphics.
-
- 3. Hercules rasterized images and EGA rasterized images are
- different, so a movie stored in rasterized Hercules form can only
- be viewed with Hercules graphics; similarly, a movie stored in
- rasterized EGA form can only be viewed with EGA graphics.
-
-
- Optimizing ANIMATE's performance
-
- When ANIMATE displays rasterized images, its most time
- consuming task by far is loading the rasterized images into video
- memory from the disk file(s) where the images are stored. You
- can do three things to make the display as fast as possible.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 12
-
-
- First, if you have two or more megabytes of memory, you can
- set aside some of that memory as a virtual disk, also called a
- RAM disk. Look up DEVICE = VDISK.SYS in your MS-DOS manual.
- ANIMATE can read a rasterized movie very rapidly from RAM disk.
- Remember that each Hercules image or each EGA bit plane occupies
- about 30 kilobytes of memory, so you will need a lot of RAM disk
- for a movie of any length.
-
- Second, make sure that your disk is not storing rasterized
- movies in "fragmented" form. If you do not know what a
- fragmented file is, fragmented files are almost certainly a
- problem on your disk. When a file is stored on a disk, it is
- entirely possible that, unknown to you, the computer may crack
- the file into two or more pieces and store the pieces on
- separated parts of the disk. This is known as fragmentation.
- The benefit of fragmentation is that it makes usable the various
- "bare" spots scattered about the disk that result when old files
- are deleted. The disadvantage of fragmentation is that it can
- slow disk access because the disk head has to jump around the
- disk to reach all the parts of a file. There are a number of
- commercially available programs that rewrite files so as to
- eliminate fragmentation. I am familiar with three
- "unfragmenters": (1) Speed Disk in the Advanced Edition of Norton
- Utilities; (2) COMPRESS in PC Tools from Central Point Software,
- and (3) VOPT from Golden Bow Systems. Any of these is good. (Be
- warned: the "quick" option on Norton Utilities' Speed Disk does
- not remove fragmentation and can actually create additional
- fragmentation; instead, use "file unfragment.") The first time
- you run an unfragmenter on your disk, it may take 10 minutes or
- more to straigthen up your files. Thereafter, it will only need
- 10-20 seconds to straighten up things if you run it regularly.
- My AUTOEXEC.BAT file invokes an unfragmenter every time I boot my
- computer.
-
- Third, the data transfer rate between your disk and your
- computer may not have been optimized by the computer
- manufacturer, specifically, the "interleave factor" may not be
- optimal. This is a "guts level" parameter that users normally do
- not alter; however, a program called SpinRite from Steve Gibson
- Research can optimize the interleave factor as well as do other
- disk maintenance tasks. Byte magazine (Nov 1988, pp. 237-239)
- has reviewed SpinRite. See also the hard disc maintenance
- packages reviewed in Byte, Jan 1990.
-
-
- Comments on ANIMATE's Tektronix 4010 emulation
-
- I coded the Tek4010 emulation based on a description of
- Tek4010 operation given in chapter 5 of the manual for the
- FlexiTek communications program marketed by Various Ware, P.O.
- Box 21070, El Cajon, CA 92021, telephone (619) 448-7126. Only
- the graphics mode of Tek4010 operation has been simulated. All
- other input is ignored.
-
- An important item which is not part of the Tek4010 graphics
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 13
-
-
- language is an "end of plot" signal. I decided to terminate a
- plot when a "clear screen" command (ASCII characters CR FF
- (hexadecimal 0d 0c)) is received or when an end of file (EOF)
- mark is encountered in the input file. Multiple plots can and
- should be in a single file, even though up to ten files can be
- chained together by ANIMATE. The limit of 10 files could be
- increased by changing the definition of MAX_FILES in ANIMATE1.C,
- but there is little reason to do this since there is no limit to
- the number of plots that can be stored in a file. In other
- words, if you can, keep all your Tektronix plotting instructions
- for a movie in one file and all your rasterized images for the
- movie in one other file.
-
-
- Modifying ANIMATE
-
- Source code for ANIMATE is provided in files ANIMATE1.C and
- ANIMATE2.C so that you can make whatever modifications you might
- like. The user will no doubt think of a number of possible
- improvements to ANIMATE, such as:
-
- 1. Emulation of a color Tektronix terminal.
- The Reference Guide for version 3 of the commercially marketed
- Macintosh VersaTerm-Pro communications package contains Chapter
- X: Appendix (pp. 288-299) seems to provide enough information
- regarding the operation of a Tektronix 4105 terminal to allow
- someone to write at least a partial emulator using Turbo C.
- VersaTerm-Pro is marketed by Synergy Software, 2457 Perkiomen
- Ave, Reading, PA 19606, telephone (215) 779-0522.
-
- 2. Allowing movies to run backwards.
-
- 3. Expanded use of script files.
-
- When I first tried writing an animation program I used Turbo
- C's getimage() and putimage() functions, but they are too slow
- for animation. Direct reads and writes from the graphics board
- are necessary, and that is why register level compatibility is
- required of your graphics board.
-
- I would be pleased to hear of your ideas and improvements.
- Before you do much work on improving ANIMATE, I would suggest
- sending me a message. That way, I can let you know whether I or
- somebody else might already be working on the improvement you
- have in mind. If you are willing to share your improvements with
- me, please take care to write clean, heavily documented code.
- Anything less is hard to maintain and almost impossible for
- another programmer to figure out.
-
- I probably will not be very quick to add additional features
- to ANIMATE. I will certainly keep your suggestions in mind and I
- hope that ANIMATE will be improved, especially by other users,
- but my job as a meteorology professor dictates that I spend the
- majority of my time doing research and teaching, not programming
- applications. I wrote ANIMATE to display the results of my
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 14
-
-
- research, and it took a LOT of time, because I was also learning
- C and PC graphics at the same time. I am basically satisfied
- with ANIMATE in its present form, although I certainly would like
- to add a Tek4105 color emulation mode, but I feel that I do not
- have the time to do that at present. I need to use ANIMATE as a
- research tool, not work on it as an end in itself.
-
- If you have Internet, you might use FTP every so often to
- sign onto the anonymous FTP account on unidata.ucar.edu (user =
- anonymous, password = guest) and check directory
- /ahlquist/animation to see whether any bugs have been discovered
- and corrected or whether a new version may be available.
-
-
- Compiling ANIMATE
-
- If you wish to recompile ANIMATE, you will need version 2 or
- newer of Borland's Turbo C.
-
- "Far" pointers are needed by _read() and _write() when
- rasterized images are placed into or read from the graphics
- board. Therefore, I have compiled ANIMATE using Turbo C's
- "compact" memory model. (Under Turbo C's Options menu, select
- Compiler, then Model Size, and Compact.) Under Options,
- Compiler, Code Generation, I turned off "OBJ debug information,"
- which trims about 6 kilobytes from ANIMATE.EXE. Nonetheless,
- leave OBJ debug information "on" if you start modifying ANIMATE,
- because the integrated debugger can be a great help.
-
- The project file ANIMATE.PRJ contains instructions for Turbo
- C on how to create ANIMATE.EXE. The project file should contain:
- ANIMATE1
- ANIMATE2
- GRAPHICS.LIB
- EGAVGA.OBJ
- HERC.OBJ
- The latter two files are created easily using Borland's BGIOBJ
- utility; see Borland's Turbo C Reference Guide for details.
-
- With compilation of the present version of ANIMATE2.C, you
- will encounter two warnings that say that variable num_bit_planes
- is not accessed in save_Herc_raster() and display_Herc_raster().
- This is okay. Hercules monochrome graphics do not use bit
- planes, but num_bit_planes is included so that the arguments to
- the Hercules routines are the same as those to save_EGA_raster()
- and display_EGA_raster(), which do need bit plane information.
- This makes it possible to use function pointers save_raster() and
- display_raster() to point to the appropriate routines. This
- avoids several "if" statements that would have to check for the
- graphics mode.
-
- You will also encounter a warning saying Tek4010() should
- return a value; it does, but all the return statements are
- within the function and none appears at the end.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 15
-
-
- Bugs in Turbo C
-
- While writing ANIMATE, I encountered the following bugs in
- Turbo C. A letter from Borland indicates that these bugs have
- not been corrected as of 18 February 1990. ANIMATE works around
- these bugs.
-
- 1. In Hercules graphics mode, cleardevice() should clear only the
- active page of video memory, but the Hercules version of
- cleardevice() clears both pages of video memory and resets the
- visual page to 0 (the first page of video memory); at least the
- active page is not reset. Occasionally, I have also had some
- trouble clearing the screen in EGA mode after accessing bit
- planes, but Borland graphics were not designed to be bomb-proof
- to attacks by a user who putzes with the guts of the graphics.
- (See point 2 below.)
-
- 2. Writing text to the screen in graphics mode using outtextxy()
- after accessing a bit plane does not always work correctly with
- EGA graphics, so I write to the screen twice, and the second time
- is ok.
-
- 3. For speed reasons, replay of rasterized images is done with
- unbuffered input/output (IO). ANSI standards implement
- unbuffered IO by calling fopen(), then setbuf(fp, NULL) to set
- the buffer size to zero, followed by use of fread() and fwrite().
- I tried to do this, both for compatibility with ANSI standards
- and to simplify the program. The problem is that Turbo C's IO
- absolutely crawls if done according to ANSI standards; it is MUCH
- slower that buffered input. Since the ANSI standard is not
- feasible, I have used _read() and _write() for unbuffered IO,
- because they are Turbo C's fastest IO routines.
-
-
-
- ANIMATE.DOC Tuesday, March 6, 1990 4:10 pm Page 16
-
-
- References
-
- In addition to the two Borland Turbo C manuals (User's Guide
- and Reference Guide), the references I used when writing ANIMATE
- are listed below. For more exposure to double buffering of
- images, I suggest that you look at the sample program MAKEMOVY.C.
-
- Schildt, Herbert, 1985: C Made Easy. Osborne McGraw-Hill,
- Berkeley, California, 292 pages. (No graphics are discussed,
- just the basics of C. There is also a version of this book
- specifically for Turbo C called Turbo C Made Easy.)
-
- Schustack, Steve, 1985: Variations in C. Microsoft Press,
- Bellevue, Washington, 344 pp. (Intermediate level guide to C; a
- good second book after one is familiar with the basics of C. No
- graphics.)
-
- Wilton, Richard, 1987: Programmer's Guide to PC & PS/2 Video
- Systems. Microsoft Press, Redmond, Washington, 531 pages. (This
- is the most comprehensive book available on programming IBM PC
- graphics. To understand this book, you need to know assembly
- language, which I do not, so almost all of it is too technical
- for me. Fortunately, Borland's Turbo C has functions to perform
- many graphics functions, and Tom Yoksas of Unidata showed me how
- to do the crucial reads and writes directly from the video board
- which make animation possible. You should be aware of this
- book's existence, but you can probably get along fine without it
- unless you want to know the register level operations of PC
- graphics.)
-
-
- Acknowledgments:
-
- ANIMATE was written to help display results of research funded by
- NSF grant ATM-8714674. Not only did this grant pay my salary
- during part of the development of ANIMATE, it also purchased some
- of the computer equipment on which the development was done.
-
- Tom Kitterman of the Florida State University Meteorology
- Department patiently answered many of my questions involving
- register level operations with graphics.
-
- During the summer of 1989, Carla Engel, an undergraduate summer
- mathematics student under NSF applied mathematics sponsorship,
- helped document the bugs which I had found in Turbo C.
-
- Tom Yoksas who works at the Unidata Project Office of the
- University Corporation for Atmospheric Research in Boulder,
- Colorado showed me how read and write directly from the graphics
- board, which makes animation possible.